let arrDemo:number[] = [6,5,7,1,8,5,7]

function select(){
    let max:number
    let maxIndex:number
    let newArr!:number[]
    arrDemo.forEach((item)=>{
        max = item
        arrDemo.forEach((iItem,iIndex)=>{
            if(max < iItem){
                max = iItem
                maxIndex = iIndex
            }
        })
        arrDemo.slice(maxIndex,1)
        newArr.push(max)
    })
    return newArr
}
const result:Array<number> = select()

console.log(result);
